use chrono::Local;
use serde::{Deserialize, Serialize};
use sqlx::types::chrono::DateTime;
use struct_field_names_as_array::FieldNamesAsSlice;

// 管理员表单数据
#[derive(sqlx::FromRow, Deserialize, Serialize, FieldNamesAsSlice)]
pub struct AdminForm { 
    // 名称
    pub name: String, 
    // 密码
    pub password: String
}

// 管理员表单数据
#[derive(sqlx::FromRow, Deserialize, Serialize, FieldNamesAsSlice)]
pub struct AdminDetail { 
    pub id: i64,
    pub name: String, 
    pub password: String,
    pub last_login: DateTime<Local>,
    pub login_count: i64,
}

// 管理员列表行数据
#[derive(sqlx::FromRow, Deserialize, Serialize, FieldNamesAsSlice)]
pub struct AdminRow { 
    pub id: i64,
    pub name: String, 
    pub last_login: DateTime<Local>,
    pub login_count: i64,
    pub created_at: DateTime<Local>,
    pub updated_at: DateTime<Local>
}
